//
//  CaculatorBrain.m
//  Caculator
//
//  Created by Lion User on 03/07/2012.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//  test

#import "CaculatorBrain.h"

@interface CaculatorBrain()
@property (nonatomic,strong) NSMutableArray *programStack;

@end


@implementation CaculatorBrain

@synthesize programStack=_programStack;

-(NSMutableArray *)programStack{
    if(_programStack ==nil)
        _programStack=[[NSMutableArray alloc] init];
    return _programStack;
}


-(void)pushOperand:(double)operand{
    [self.programStack addObject:[NSNumber numberWithDouble:operand]];   
}

-(double)popOperand{
    NSNumber *operandObject=[self.programStack lastObject];
    if(operandObject)
        [self.programStack removeLastObject];
    return [operandObject doubleValue];
}



-(double)performOperation:(NSString *)operation{
    [self.programStack addObject:operation];
    [CaculatorBrain runProgram:self.program];
}

-(id)program{
    
}

//    double result=0;
//    if([operation isEqualToString:@"+"]){
//        result = [self popOperand]+[self popOperand];
//    }else  if([operation isEqualToString:@"-"]){
//        result = [self popOperand]-[self popOperand];
//    }else  if([operation isEqualToString:@"*"]){
//        result = [self popOperand]*[self popOperand];
//    }else  if([operation isEqualToString:@"/"]){
//        result = [self popOperand]/[self popOperand];
//    }
//    
//    [self pushOperand:result];
//    return result;    
//}


@end
